<script>
import outMain from "@/components/outMain.vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { Rechargerecord, RechargeRecordStatistics } from "@/http/api";

export default {
  components: { outMain },
  name: "",
  data() {
    return {
      tableData: [],
      totalData: {},
      statusArr: [
        { label: "全部", value: "" },
        { label: "企业端", value: "1" },
        { label: "培训端", value: "2" },
        { label: "船东端", value: "2" },
      ],
      queryData: {
        terminal_type: "",
        order_number: "",
        page: 1,
        per_page: 10,
      },
      total: 0,
    };
  },
  props: {},
  setup() {},
  methods: {
    getData() {
      Rechargerecord(this.queryData).then((res) => {
        if (res.data.code == 1) {
          this.tableData = res.data.data.data;
          this.total = res.data.data.total;
        }
      });
    },
    getTotal() {
      RechargeRecordStatistics().then((res) => {
        if (res.data.code == 1) {
          this.totalData = res.data.data;
        }
      });
    },
  },
  mounted() {},
  created() {
    this.getData();
    this.getTotal();
  },
};
</script>
<template>
  <outMain>
    <div class="cardCont">
      <div class="carItem">
        <div class="carName">总计金额</div>
        <div class="carText">
          ¥{{
            (
              Number(totalData.qy_money) +
              Number(totalData.cd_money) +
              Number(totalData.px_money)
            ).toFixed(2)
          }}
        </div>
      </div>
      <div class="carItem">
        <div class="carName">企业端</div>
        <div class="carText">¥{{ totalData.qy_money }}</div>
      </div>
      <div class="carItem">
        <div class="carName">培训端</div>
        <div class="carText">¥{{ totalData.px_money }}</div>
      </div>
      <div class="carItem">
        <div class="carName">船东端</div>
        <div class="carText">¥{{ totalData.cd_money }}</div>
      </div>
    </div>
    <div class="tableCont">
      <div class="tableName flexCont">
        <div>后台充值记录（{{ total }}）</div>
      </div>
      <div class="tableSerch">
        <div class="serchLeft"></div>
        <div class="serchRight">
          <el-form class="flexCenter" :inline="true">
            <el-form-item>
              <el-input
                clearable
                @clear="getData"
                @keyup.enter="getData"
                v-model="queryData.order_number"
                placeholder="请输入订单号"
              />
            </el-form-item>
            <el-form-item>
              <el-select
                v-model="queryData.terminal_type"
                clearable
                @change="getData"
                placeholder="请选择充值平台"
              >
                <el-option
                  v-for="item in statusArr"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
            <btn value="搜索" @click="getData"></btn>
          </el-form>
        </div>
      </div>
      <el-table class="tableMain" :data="tableData" stripe style="width: 100%">
        <el-table-column
          prop="order_number"
          width="200"
          show-overflow-tooltip
          label="订单号"
        />
        <el-table-column
          prop="comUser"
          width="120"
          show-overflow-tooltip
          label="充值平台"
        >
          <template #default="{ row }">
            <div v-if="row.terminal_type == 1">企业端</div>
            <div v-if="row.terminal_type == 2">培训端</div>
            <div v-if="row.terminal_type == 3">船东端</div>
          </template>
        </el-table-column>
        <el-table-column
          prop="account_name"
          width="220"
          show-overflow-tooltip
          label="充值账号"
        />
        <el-table-column
          prop="pay_money"
          width="150"
          show-overflow-tooltip
          label="充值金额"
        >
          <template #default="{ row }">{{ row.pay_money }}（元）</template>
        </el-table-column>
        <el-table-column prop="msg" show-overflow-tooltip label="充值内容" />
        <el-table-column
          prop="pay_time"
          show-overflow-tooltip
          width="200"
          label="支付时间"
        />
      </el-table>
      <div class="pageCont">
        <el-pagination
          v-model:currentPage="queryData.page"
          v-model:page-size="queryData.per_page"
          background
          layout="total, prev, pager, next, jumper"
          :total="total"
          @size-change="getData"
          @current-change="getData"
        />
      </div>
    </div>
  </outMain>
</template>
<style scoped lang="less"></style>
